package org.app.appjson.reader.jsonnode;

import java.util.Map;

/**
 * json节点
 * @author lizhongsi
 * @version 1.0
 * @since 1.0
 */
public class JsonNode {

    private final Object object;

    public JsonNode(Object object) {
        this.object = object;
    }

    public JsonNode getNode(String nodeName) {
        if (!(this.object instanceof Map)) { //true when object == null
            return null;
        }
        Map<Object, Object> map = (Map<Object, Object>) this.object;
        return new JsonNode(map.get(nodeName));
    }

    public <T> T value() {
        return (T) this.object;
    }
}
